package com.ruoyi.bantong.controller;

import java.util.List;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.bantong.domain.BtRedbagBlacklist;
import com.ruoyi.bantong.service.IBtRedbagBlacklistService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 红包玩法黑名单Controller
 * 
 * @author laohei
 * @date 2021-02-06
 */
@RestController
@RequestMapping("/bantong/redbagblacklist")
public class BtRedbagBlacklistController extends BaseController
{
    @Autowired
    private IBtRedbagBlacklistService btRedbagBlacklistService;

    /**
     * 查询红包玩法黑名单列表
     */
    //@PreAuthorize("@ss.hasPermi('bantong:blacklist:list')")
    @GetMapping("/list")
    public TableDataInfo list(BtRedbagBlacklist btRedbagBlacklist)
    {
        startPage();
        List<BtRedbagBlacklist> list = btRedbagBlacklistService.selectBtRedbagBlacklistList(btRedbagBlacklist);
        return getDataTable(list);
    }

    /**
     * 导出红包玩法黑名单列表
     */
    //@PreAuthorize("@ss.hasPermi('bantong:blacklist:export')")
    @Log(title = "红包玩法黑名单", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(BtRedbagBlacklist btRedbagBlacklist)
    {
        List<BtRedbagBlacklist> list = btRedbagBlacklistService.selectBtRedbagBlacklistList(btRedbagBlacklist);
        ExcelUtil<BtRedbagBlacklist> util = new ExcelUtil<BtRedbagBlacklist>(BtRedbagBlacklist.class);
        return util.exportExcel(list, "blacklist");
    }

    /**
     * 获取红包玩法黑名单详细信息
     */
    //@PreAuthorize("@ss.hasPermi('bantong:blacklist:query')")
    @GetMapping(value = "/{rbId}")
    public AjaxResult getInfo(@PathVariable("rbId") Integer rbId)
    {
        return AjaxResult.success(btRedbagBlacklistService.selectBtRedbagBlacklistById(rbId));
    }

    /**
     * 新增红包玩法黑名单
     */
    //@PreAuthorize("@ss.hasPermi('bantong:blacklist:add')")
    @Log(title = "红包玩法黑名单", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody BtRedbagBlacklist btRedbagBlacklist)
    {
        return toAjax(btRedbagBlacklistService.insertBtRedbagBlacklist(btRedbagBlacklist));
    }

    /**
     * 修改红包玩法黑名单
     */
    //@PreAuthorize("@ss.hasPermi('bantong:blacklist:edit')")
    @Log(title = "红包玩法黑名单", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody BtRedbagBlacklist btRedbagBlacklist)
    {
        return toAjax(btRedbagBlacklistService.updateBtRedbagBlacklist(btRedbagBlacklist));
    }

    /**
     * 删除红包玩法黑名单
     */
    //@PreAuthorize("@ss.hasPermi('bantong:blacklist:remove')")
    @Log(title = "红包玩法黑名单", businessType = BusinessType.DELETE)
	@DeleteMapping("/{rbIds}")
    public AjaxResult remove(@PathVariable Integer[] rbIds)
    {
        return toAjax(btRedbagBlacklistService.deleteBtRedbagBlacklistByIds(rbIds));
    }
}
